/***************************************************************************
 *   KShootout - online shootout card game.                                *
 *   Copyright (C) 2008, 2009  MacJariel                                   *
 *                                                                         *
 *   KShootout is free software: you can redistribute it and/or modify     *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation, either version 3 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   KShootout is distributed in the hope that it will be useful,          *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with KShootout.  If not, see <http://www.gnu.org/licenses/>.    *
 ***************************************************************************/
#ifndef ACTIONPARSER_H
#define ACTIONPARSER_H

/*[[[cog
import cog
from actiondefs import *
]]]
[[[end]]]*/

#include "actions.h"
#include <QXmlStreamWriter>
#include "parser/xmlnode.h"

class ActionParser
{
public:
    static QString elementName(ActionData::Type);

    static void write(QXmlStreamWriter*, const ActionDataPtr&);
    static ActionDataPtr read(XmlNode*);

    /*[[[cog
    for a in Actions:
        cog.outl("static void write%(actionName)s(QXmlStreamWriter*, const %(structName)sPtr&);" % a)
        cog.outl("static %(structName)sPtr read%(actionName)s(XmlNode*);" % a)
        cog.outl("");
    ]]]*/
    static void writeChatMessage(QXmlStreamWriter*, const ActionChatMessageDataPtr&);
    static ActionChatMessageDataPtr readChatMessage(XmlNode*);

    static void writeCreateGame(QXmlStreamWriter*, const ActionCreateGameDataPtr&);
    static ActionCreateGameDataPtr readCreateGame(XmlNode*);

    static void writeDiscard(QXmlStreamWriter*, const ActionDiscardDataPtr&);
    static ActionDiscardDataPtr readDiscard(XmlNode*);

    static void writeDrawCard(QXmlStreamWriter*, const ActionDrawCardDataPtr&);
    static ActionDrawCardDataPtr readDrawCard(XmlNode*);

    static void writeEndTurn(QXmlStreamWriter*, const ActionEndTurnDataPtr&);
    static ActionEndTurnDataPtr readEndTurn(XmlNode*);

    static void writeJoinGame(QXmlStreamWriter*, const ActionJoinGameDataPtr&);
    static ActionJoinGameDataPtr readJoinGame(XmlNode*);

    static void writeLeaveGame(QXmlStreamWriter*, const ActionLeaveGameDataPtr&);
    static ActionLeaveGameDataPtr readLeaveGame(XmlNode*);

    static void writePass(QXmlStreamWriter*, const ActionPassDataPtr&);
    static ActionPassDataPtr readPass(XmlNode*);

    static void writePlayCard(QXmlStreamWriter*, const ActionPlayCardDataPtr&);
    static ActionPlayCardDataPtr readPlayCard(XmlNode*);

    static void writeStartGame(QXmlStreamWriter*, const ActionStartGameDataPtr&);
    static ActionStartGameDataPtr readStartGame(XmlNode*);

    static void writeUseAbility(QXmlStreamWriter*, const ActionUseAbilityDataPtr&);
    static ActionUseAbilityDataPtr readUseAbility(XmlNode*);

    //[[[end]]]
};

#endif // ACTIONPARSER_H
